@import '@/styles/utils.scss';

.viewport {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 390px;
  max-width: 100vw;
  margin: 0;
  list-style: none;
  z-index: 9999;
  outline: none;
  padding: 20px;
}

.toastRoot {
  background-color: white;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 15px;
  display: grid;
  grid-template-areas: "icon content close";
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  backdrop-filter: blur(8px);
  animation: slideIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
  
  &[data-state="open"] {
    animation: slideIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  &[data-state="closed"] {
    animation: hide 100ms ease-in;
  }

  &[data-swipe="move"] {
    transform: translateX(var(--radix-toast-swipe-move-x));
  }

  &[data-swipe="cancel"] {
    transform: translateX(0);
    transition: transform 200ms ease-out;
  }

  &[data-swipe="end"] {
    animation: swipeOut 100ms ease-out;
  }

  :global(.dark) & {
    background-color: #27272A;
    color: white;
  }
}

.iconContainer {
  grid-area: icon;
  display: flex;
  align-items: center;
}

.description {
  grid-area: content;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
}

.closeButton {
  grid-area: close;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;

  &:hover {
    opacity: 1;
  }
}

.closeIcon {
  font-size: 18px;
  line-height: 1;
}

.success {
  .iconContainer {
    color: #22C55E;
  }
}

.error {
  .iconContainer {
    color: #EF4444;
  }
}

.warning {
  .iconContainer {
    color: #F59E0B;
  }
}

.info {
  .iconContainer {
    color: #3B82F6;
  }
}

@keyframes hide {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(calc(100% + 20px));
  }
  to {
    transform: translateX(0);
  }
}

@keyframes swipeOut {
  from {
    transform: translateX(var(--radix-toast-swipe-end-x));
  }
  to {
    transform: translateX(calc(100% + 20px));
  }
}
